<!DOCTYPE html>
<html class="x-admin-sm">

	<head>
		<meta charset="UTF-8">
		<title>推荐课程</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/xadmin.css">
		<script src="./lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="./js/xadmin.js"></script>
	</head>

	<body>
		<div class="x-nav">
			<span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
			<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
				<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
		</div>
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card" id="app">
						<div class="layui-card-body ">
							<form class="layui-form layui-col-space5">
								<div class="layui-form-item">
									<label for="username" class="layui-form-label">
		                            <span class="x-red">*</span>课程名称</label>
									<div class="layui-input-inline">
										<input type="text" readonly="readonly" :value="courseDto.courseName" lay-verify="required" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label for="username" class="layui-form-label">
		                            <span class="x-red">*</span>课程简介</label>
									<div class="layui-input-inline">
										<input type="text" readonly="readonly" :value="courseDto.title" lay-verify="required" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label for="username" class="layui-form-label">
		                            <span class="x-red">*</span>排序值</label>
									<div class="layui-input-inline">
										<input type="number" :value="courseDto.tid" id="orderNum" lay-verify="required" autocomplete="off" class="layui-input">
									</div>
								</div>

								<div class="layui-form-item">
									<label for="L_repass" class="layui-form-label"></label>
									<button class="layui-btn" lay-filter="add" type="button" @click="addWeb">提交</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="./js/jquery.min.js"></script>
	<script type="text/javascript" src="js/vue.js"></script>
	<script src="./js/vue.min.js"></script>
	<script src="js/axios.min.js"></script>
	<script type="text/javascript" src="js/jquery.cookie.js"></script>
	<script>
		const app = new Vue({
			el: "#app",
			data: {
				courseDto: ''
			},
			methods: {
				addWeb(){
					var id = $.cookie("webId");
					var order = $("#orderNum").val();
					if (order<0 || order>8){
						alert("排序值最低为0,最高为8");
						return;
					} 
					$.ajax({
						type:"post",
						url:"http://localhost:9095/admin/courseDetail/editDetail",
						async:true,
						data:{
							"courseId": id,
							"orderNum": order
						},
						headers: {
							"token2": $.cookie("token2")
						},
						success:function(msg){
							if(msg.code==200){
			                    layer.alert(msg.message, {
			                        icon: 6
			                    },
			                    function() {
			                        //关闭当前frame
			                        xadmin.close();
			                        // 可以对父窗口进行刷新 
			                        xadmin.father_reload();
			                    });
			                    return false;
							} else {
								layer.alert(msg.message, {
			                        icon: 3
			                   	},
			                   	function(){
			                   	
			                   	})
							}
						}
					});
				}
			},
			created() {
				var webId = $.cookie("webId");
				let _this = this;
				$.ajax({
					type:"get",
					url:"http://localhost:9095/admin/courseDetail/getWebsitCourse",
					async:true,
					data:{
						"courseId": webId
					},
					headers: {
						"token2": $.cookie("token2")
					},
					success: function(response){
						console.log(response)
						_this.courseDto = response.data;
					}
				});
//				$.get("http://localhost:9095/admin/courseDetail/getWebsitCourse", {
//					"courseId": webId
//				}).then(function(response) {
//					console.log(response)
//					_this.courseDto = response.data;
//				});
			}
		})

		layui.use(['laydate', 'form'], function() {
			var laydate = layui.laydate;
			var form = layui.form;
		});
	</script>

	<script>
		var _hmt = _hmt || [];
		(function() {
			var hm = document.createElement("script");
			hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
			var s = document.getElementsByTagName("script")[0];
			s.parentNode.insertBefore(hm, s);
		})();
	</script>

</html>